# +================================================================+
# =                         basic setting                          =
# +================================================================+
# 设置自定义前缀
unbind C-b
set -g prefix C-f

# 退出tmux
bind -n M-q detach-client

# reload
bind -n M-r source-file ~/.dotfiles/tmux/tmux.conf \; display-message Reloaded!

# set-hook -g client-attached 'run "xmodmap ~/.dotfiles/misc/.uxmodmap"'
# set-hook -g client-detached 'run "xmodmap ~/.dotfiles/misc/.xmodmap"'
# set-hook -g client-attached 'run "unkeymap"'
# set-hook -g client-detached 'run "keymap"'
# set-hook -g after-select-pane 'run "unkeymap"'
# set-hook -g client-detached 'run "keymap"'



# +================================================================+
# =                          pane setting                          =
# +================================================================+
# 新建pane
bind -n M-n split-window -h -c '#{pane_current_path}'
bind -n M-N split-window -c '#{pane_current_path}'

# 关闭pane
bind -n M-w confirm-before -p "kill-pane #P? (y/n)" kill-pane
# bind -n M-w kill-pane

# 选择pane
bind -n M-k select-pane -U
bind -n M-j select-pane -D
bind -n M-h select-pane -L
bind -n M-l select-pane -R

# 交换pane
bind -n M-K swap-pane -U
bind -n M-J swap-pane -D
bind -n M-H swap-pane -U
bind -n M-L swap-pane -D

# 全屏pane
bind -n M-f resize-pane -Z

bind -n M-! join-pane -t :=1
bind -n M-@ join-pane -t :=2
# bind -n M-# join-pane -t :=3
bind -n M-$ join-pane -t :=4
bind -n M-% join-pane -t :=5
bind -n M-^ join-pane -t :=6
bind -n M-& join-pane -t :=7
bind -n M-* join-pane -t :=8
bind -n M-( join-pane -t :=9
bind -n M-) join-pane -t :=0


# +================================================================+
# =                         window setting                         =
# +================================================================+
# 新建window
bind -n M-enter new-window -c '#{pane_current_path}'

# 选择window
bind -n M-0 select-window -t :=0
bind -n M-1 select-window -t :=1
bind -n M-2 select-window -t :=2
bind -n M-3 select-window -t :=3
bind -n M-4 select-window -t :=4
bind -n M-5 select-window -t :=5
bind -n M-6 select-window -t :=6
bind -n M-7 select-window -t :=7
bind -n M-8 select-window -t :=8
bind -n M-9 select-window -t :=9
bind -n M-[ previous-window
bind -n M-] next-window

# +================================================================+
# =                        session setting                         =
# +================================================================+
# 切换session
bind -n M-{ switch-client -p
bind -n M-} switch-client -n




# +================================================================+
# =                         color setting                          =
# +================================================================+
# 设置256色模式
set -g default-terminal "screen-256color"
set -ga terminal-overrides ",xterm-256color:Tc"

tm_color_active=colour15
tm_color_inactive=colour241
tm_color_feature=colour210
tm_color_music=colour215
tm_active_border_color=colour240


# +================================================================+
# =                       status bar setting                       =
# +================================================================+
bind -n M-s set status

set -g status-left-length 32
set -g status-right-length 150
set -g status-interval 5
# set -g status-fg $tm_color_active
set -g status-fg default
set -g status-bg default

tm_session_name="#[fg=$tm_color_feature,bold]#S"
set -g status-left "$tm_session_name "

tm_signature="(✪ ω ✪ )  ni shi zui bang de !"
tm_date="#[fg=$tm_color_inactive] %b-%d %R"
tm_host="#[fg=$tm_color_feature,bold]#h"
set -g status-right "$lm_date $tm_host"

# pane number display
set -g display-panes-active-colour $tm_color_active
set -g display-panes-colour $tm_color_inactive

# set -g window-status-format "#I #W"
setw -g window-status-format "#I"
setw -g window-status-current-format "#[bold]#I"

# pane border
# set -g pane-border-fg $tm_color_inactive
# set -g pane-active-border-fg $tm_active_border_color

# message text
# set -g message-bg default
# set -g message-fg $tm_color_active




# +================================================================+
# =                          misc setting                          =
# +================================================================+
set -g base-index 1
set -g pane-base-index 1

# 修改默认延时
set -sg escape-time 1

# 鼠标
set -g mouse on
setw -g mode-keys vi

# 复制模式
bind -n M-c copy-mode
bind -n M-v paste-buffer

# 默认路径
# set default-path "$PWD"

# 时钟
setw -g clock-mode-colour $tm_color_active

set -g history-limit 10000
